﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace Coolzon.UI.Core.Parts
{
    public interface IPartContainer
    {
        /// <summary>
        /// 获取子组件列表
        /// </summary>
        /// <returns></returns>
        List<Widget> GetPartList();

        /// <summary>
        /// 添加子组件
        /// </summary>
        /// <param name="part"></param>
        void AddPart(Widget part);

        /// <summary>
        /// 删除子组件
        /// </summary>
        /// <param name="part"></param>
        void XRemovePart(Widget part);

        /// <summary>
        /// 根据组件名称获取组件
        /// </summary>
        /// <param name="partName"></param>
        /// <param name="isRecursive">是否递归获取</param>
        /// <returns></returns>
        Widget GetChildPart(string partName, bool isRecursive);

        /// <summary>
        /// 根据类型来获取组件里包含的子组件
        /// </summary>
        /// <param name="isRecursive"></param>
        /// <returns></returns>
        List<T> GetChildPartByType<T>(bool isRecursive);

        /// <summary>
        /// 验证类型是否允许添加到容器中
        /// </summary>
        /// <param name="childType"></param>
        /// <returns></returns>
        bool ValidateChildType(Type childType);

        UIElement GetContentContainer();

        /// <summary>
        /// 获取容器的实际的位置，因为容器外围有一些其他的显示内容，真正显示子组件的区域比这个小。
        /// </summary>
        /// <returns></returns>
        Point XGetContentPos();

        /// <summary>
        /// 移动到指定位置
        /// </summary>
        /// <param name="part"></param>
        /// <param name="index"></param>
        void BringPartTo(Widget part, int index);
        /// <summary>
        /// 获取组件当前位置
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        int GetPartIndex(Widget part);
        /// <summary>
        /// 获取组件的最底层位置
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        int GetSendToBackIndex(Widget part);
        /// <summary>
        /// 获取组件最顶层位置
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        int GetBringToFrontIndex(Widget part);
        /// <summary>
        /// 获取组件上一层位置
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        int GetForwardIndex(Widget part);
        /// <summary>
        /// 获取组件下一层位置
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        int GetBackwardIndex(Widget part);

        Tuple<Point?, Point?, byte> GetAlignLinePoint(Widget part, double left = -1, double top = -1, double right = -1, double bottom = -1);
    }
}
